<?php
/*
Module: RadLib_MACRO.php
Description: Kazoo library to allow template nodes to be used as macros.
*/

// Library Class Definition
class MACRO {
	function tag_MACRO($node) {
		if (!$node->hasParam("var", "var") || !$node->hasParam("exec", "exec"))
			return;
		$var = $node->getParam("var");
		$node->assign($var, $node);
		$var = $node->getParam("exec");
		if (strcasecmp($var, "true"))
			$node->getEngine()->parseNodes($node);
	}

	function tag_REPLAY($node) {
		if (!$node->hasParam("var", "var"))
			return;
		$var = $node->getParam("var");
		$rnode = $node->evalParam($var);
		$node->push();
		$rnode->evalNodes();
		$node->pop();
	}

	public function __construct($plugin) {
		$plugin->setTagHandlerFunc("macro", "tag_MACRO", $this);
		$plugin->setTagHandlerFunc("replay", "tag_REPLAY", $this);
	}
}
?>